<%@page import="ae.pcfc.etks.online.itworx.ehs.web.constants.GlobalConstants"%>
<%@page import="org.springframework.security.core.Authentication" %>
<%@page import="org.springframework.security.core.context.SecurityContextHolder" %>
<%@page import="org.springframework.security.core.userdetails.UserDetails" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%
			String type = (String) request.getParameter("type");
			//String username = request.getUserPrincipal().getName();
			//Authentication auth = SecurityContextHolder.getContext().getAuthentication();
			//Object principal = auth.getPrincipal();
			//String username = "";
			
			//if (principal instanceof UserDetails) {
			//	username= ((UserDetails) principal).getUsername();
			//} else {
			//	username = principal.toString();
			//}
			
			//String username = request.getRemoteUser();
			if (null == type) {
				type = "";
			}
			
			//String customerRole = "ROLE_"+GlobalConstants.CUSTOMER_ROLE;
		%>
		
<sec:authorize access="isAuthenticated()">
<sec:authorize access="hasAnyRole('ROLE_EHS_CUSTOMER','ROLE_EHS_OFFICER')"> 

<div class="t_menu-heading"><spring:message code="lable.menu.trakhees"/></div>
<ul class="topnav">
	<li <%= (type.equals("New") || type.equals("Amendment") || type.equals("Renewal"))? "class='current first'" : ""%>><img class="imgitem"
		src="resources/images/new-request.png" /><a href="javascript:void(0)"><spring:message code="label.menu.newRequest"/></a>
		<ul>
			<c:choose>
				<c:when test='<%= type.equals("New") %>'>
					<li class="current active">
				</c:when>
				<c:otherwise>
					<li>
				</c:otherwise>
			</c:choose>

			<sec:authorize access="hasRole('ROLE_EHS_CUSTOMER')">
				<a href="client/create.htm?type=New"><spring:message code="label.menu.newRequest.new"/></a>
			</sec:authorize>
			<sec:authorize access="hasAnyRole('ROLE_EHS_OFFICER')">
				<a href="officer/selectTksUsers.htm?type=New"><spring:message code="label.menu.newRequest.new"/></a>
			</sec:authorize>
			
			
	</li>
	<c:choose>
		<c:when test='<%= type.equals("Amendment") %>'>
			<li class="current active">
		</c:when>
		<c:otherwise>
			<li>
		</c:otherwise>
	</c:choose>
		<sec:authorize access="hasRole('ROLE_EHS_CUSTOMER')">
			<a href="client/create.htm?type=Amendment"><spring:message code="label.menu.newRequest.amendment"/></a>
		</sec:authorize>
		<sec:authorize access="hasAnyRole('ROLE_EHS_OFFICER')">
			<a href="officer/selectTksUsers.htm?type=Amendment"><spring:message code="label.menu.newRequest.amendment"/></a>
		</sec:authorize>
	</li>
	<c:choose>
		<c:when test='<%= type.equals("Renewal") %>'>
			<li class="current active">
		</c:when>
		<c:otherwise>
			<li>
		</c:otherwise>
	</c:choose>
	
		<sec:authorize access="hasRole('ROLE_EHS_CUSTOMER')">
			<a href="client/create.htm?type=Renewal"><spring:message code="label.menu.newRequest.renewal"/></a>
		</sec:authorize>
		<sec:authorize access="hasAnyRole('ROLE_EHS_OFFICER')">
			<a href="officer/selectTksUsers.htm?type=Renewal"><spring:message code="label.menu.newRequest.renewal"/></a>
		</sec:authorize>
	</li>
</ul>
</li>
<li <%= type.equals("inbox") || type.equals("myRequests")? "class='current first'" : "" %>>

<img class="imgitem"
		src="resources/images/inbox.png" /><a href="javascript:void(0)"><spring:message code="label.menu.mySubmission"/></a>
	<ul>	
<c:choose>
	<c:when test='<%= type.equals("inbox") %>'>
		<li class="current active">
	</c:when>
	<c:otherwise>
		<li>
	</c:otherwise>
</c:choose>
<sec:authorize access="hasAnyRole('ROLE_EHS_OFFICER')">
		<a href="officer/viewInbox.htm?type=inbox"><spring:message code="label.menu.inbox"/></a>
		</li>
</sec:authorize>

<sec:authorize access="hasRole('ROLE_EHS_CUSTOMER')">
		<a href="client/viewInbox.htm?type=inbox"><spring:message code="label.menu.inbox"/></a>
		</li>
</sec:authorize>

<c:choose>
	<c:when test='<%=type.equals("myRequests") %>'>
		<li class="current active">
	</c:when>
	<c:otherwise>
		<li>
	</c:otherwise>
</c:choose>
<sec:authorize access="hasAnyRole('ROLE_EHS_OFFICER')">
		<a href="officer/listRequests.htm?type=myRequests"><spring:message code="label.menu.allRequests"/></a>
</sec:authorize>
<sec:authorize access="hasRole('ROLE_EHS_CUSTOMER')">
		<a href="client/listRequests.htm?type=myRequests"><spring:message code="label.menu.allRequests"/></a>
</sec:authorize>

</li>
</ul>
</li>
<sec:authorize access="hasAnyRole('ROLE_EHS_OFFICER')">
<c:choose>
	<c:when test='<%=type.equals("unassigned") %>'>
		<li class="current">
	</c:when>
	<c:otherwise>
		<li>
	</c:otherwise>
</c:choose>
	<img class="imgitem" src="resources/images/my-requests.png" />
	<a href="officer/unassignedRequests.htm?type=unassigned"><spring:message code="label.menu.unassignedRequests"/></a>
</li>
</sec:authorize>
</ul>
<div class="bg_MenuBottom"></div>
</sec:authorize>
</sec:authorize>